package cn.gok.lambda;

import java.util.HashMap;
import java.util.Hashtable;
import java.util.LinkedHashMap;
import java.util.concurrent.ConcurrentHashMap;

public class 其他Map实现类 {
    public static void main(String[] args) {
        //LinkedHashMap例子();
        //Hashtable例子();
        ConcurrentHashMap例子();
    }

    private static void ConcurrentHashMap例子() {
        ConcurrentHashMap<String, String> map = new ConcurrentHashMap<>();
        map.put("aaa","bbb");
    }

    private static void Hashtable例子() {
        //HashMap可以为空，HashTable不行
        Hashtable<String, String> map = new Hashtable<>();
        map.put("aaa","111");
        map.put("bbb",null);
    }

    private static void LinkedHashMap例子() {
        LinkedHashMap<String, String> map = new LinkedHashMap<>();
        map.put("aaa","111");
        map.put("bbb","2222");
        map.put("a","3333");
        map.put("bbbbb","44444");
        System.out.println(map);
    }
}
